When used in interactive mode (in the IDL Workbench or in a command shell session — anywhere you see the IDL> prompt) IDL automatically compiles and executes a user-written function or procedure when it is first referenced if:
IDL does not search for files to compile or restore in runtime mode. When using the IDL Virtual Machine or any other runtime mechanism, all routines required by the application must either be restored when the application is initially loaded, or restored explicitly by the application code.
Note: IDL is case-insensitive. However, for some operating systems, IDL only checks for the lowercase filename based on the name of the procedure or function. We recommend that all filenames be lowercase letters.
Note: User-written functions must be defined before they are referenced, unless they meet the above conditions for automatic compilation, or the function name has been reserved by using the FORWARD_FUNCTION statement described below. This restriction is necessary in order to distinguish between function calls and subscripted variable references.
For more information on how to access routines, see Running Named Programs .
If multiple .pro or .sav files with the same base name exist in the directories specified by the !PATH system variable, IDL will compile or restore the first file it finds, according to the following rules:
Attempt to call undefined procedure/function
error, and halts execution.Versions of IDL prior to version 5.0 used parentheses to indicate array subscripts. Because function calls use parentheses as well, the IDL compiler is not able to distinguish between arrays and functions by examining the statement syntax.
User-defined functions, with the exception of those contained in directories specified by the IDL system variable !PATH, must be compiled before the first reference to the function is encountered. This is necessary because the IDL compiler is unable to distinguish between a reference to a variable subscripted with parentheses and a call to a presently undefined user function with the same name. For example, in the statement:
A = XYZ(5)
it is impossible to tell by context alone if XYZ is an array or a function.
Note: In versions of IDL prior to version 5.0, parentheses were used to enclose array subscripts. While using parentheses to enclose array subscripts will continue to work as in previous version of IDL, we strongly suggest that you use brackets in all new code. See Array Subscript Syntax: [ ] vs. ( ) for additional details.
When IDL encounters references that may be either a function call or a subscripted variable, it searches the current directory, then the directories specified by !PATH, for files with names that match the unknown function or variable name. If one or more files matching the unknown name exist, IDL compiles them before attempting to evaluate the expression. If no function or variable with the given name exists, IDL displays an error message.
There are several ways to avoid this problem: